package com.zikao.article.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zikao.article.entity.TextEntity;
import com.zikao.article.service.TextService;
import com.zikao.common.utils.PageUtils;
import com.zikao.common.utils.R;



/**
 * 
 *
 * @author likaisheng
 * @email 1805318928@qq.com
 * @date 2021-02-21 10:55:38
 */
@RestController
@RequestMapping("article/text")
public class TextController {
    @Autowired
    private TextService textService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("article:text:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = textService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("article:text:info")
    public R info(@PathVariable("id") Long id){
		TextEntity text = textService.getById(id);

        return R.ok().put("text", text);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("article:text:save")
    public R save(@RequestBody TextEntity text){
		textService.save(text);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("article:text:update")
    public R update(@RequestBody TextEntity text){
		textService.updateById(text);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("article:text:delete")
    public R delete(@RequestBody Long[] ids){
		textService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
